<%@page import="java.util.Date"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
<title>用户列表</title>
<meta name="decorator" content="default" />
<script type="text/javascript">
	function page(n, s) {
		$("#pageNo").val(n);
		$("#pageSize").val(s);
		$("#searchForm").submit();
		return false;
	}
</script>
</head>
<body>
	<div class="boxcontent">
		<div class="content">
			<form:form id="searchForm" modelAttribute="user"
				action="${ctx}/sys/user/dialogUserListByAccount" method="post"
				class="breadcrumb form-search ">
				<input id="pageNo" name="pageNo" type="hidden"
					value="${page.pageNo}" />
				<input id="pageSize" name="pageSize" type="hidden"
					value="${page.pageSize}" />
				<sys:tableSort id="orderBy" name="orderBy" value="${page.orderBy}"
					callback="page();" />
				<table class="t-search">
					<tr>
						<td>登陆名：</td>
						<td><form:input path="loginName" htmlEscape="false"
								maxlength="50" class="input-search" /></td>
						<td>姓名：</td>
						<td><form:input path="name" htmlEscape="false" maxlength="50"
								class="input-search" /></td>
						<td class="tb-btn"><input id="btnSubmit"
							class="btn btn-primary" type="submit" value="查询"
							onclick="return page();" /> <input type="button" id="reset_"
							class="reset btn" value="重置" /></td>
					</tr>
				</table>
			</form:form>
			<div class="tbbox firsttdCenter">
				<div class="boxthead">
					<div class="autobox">
						<table cellpadding="0" cellspacing="0"
							class="table table-bordered tbhead">
							<thead>
								<tr>
									<th ><input type="checkbox"
										class="checkall" /></th>
									<th class="sort-column login_name">登录名</th>
									<th class="sort-column name">姓名</th>
									<th>归属部门</th>
									<th>归属公司</th>
								</tr>
							</thead>
						</table>
					</div>
				</div>
				<div class="boxbody ">
					<table cellpadding="0" cellspacing="0"
						class="table table-bordered tbbody">
						<tbody>
							<c:if test="${empty page.list}">
								<tr class="undata">
									<td class="center" colspan=5>没有数据</td>
								</tr>
							</c:if>
							<c:forEach items="${page.list}" var="user">
								<tr>
									<td><input type="checkbox" data-param="id=${user.id}" />
										<input type="hidden" id="id" name="id" value="${user.id}" />
										<input type="hidden" id="no" name="no" value="${user.no}" />
										<input type="hidden" id="name" name="name"
										value="${user.name}" /></td>
									<td>${user.loginName}</td>
									<td>${user.name}</td>
									<td>${user.office.name}</td>
									<td>${user.company.name}</td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
					<div class="pagination">${page}</div>
				</div>
			</div>
		</div>
	</div>
	<script>
		var selects = '${param.selected}' == "true" ? true : false; //false 单选   true 可以多选
		if (selects) {
			$(".checkall").removeAttr("disabled");
		} else {
			$(".checkall").attr("disabled", "disabled");
		}

		$(".boxbody tr").click(
				function() {
					if (selects) {
						if ($(this).hasClass("trselected")) {
							$(this).removeClass("trselected");
							$(this).find("td:first input[type=checkbox]").prop(
									"checked", false);
						} else {
							$(this).addClass("trselected");
							$(this).find("td:first input[type=checkbox]").prop(
									"checked", true);
						}
					} else {
						$(this).addClass("trselected");
						$(this).find("td:first input[type=checkbox]").prop(
								"checked", true);
						$(this).siblings().removeClass("trselected");
						$(this).siblings()
								.find("td:first input[type=checkbox]").prop(
										"checked", false);
					}
				});

		$(".checkall").click(
				function() {
					if ($(this).is(":checked")) {
						$(this).parents(".boxthead").next(".boxbody").find(
								"tr:visible").addClass("trselected");
						$(this).parents(".boxthead").next(".boxbody").find(
								"tr:visible").find(
								"td:first input[type=checkbox]").prop(
								"checked", true);
					} else {
						$(this).parents(".boxthead").next(".boxbody").find(
								"tr:visible").removeClass("trselected");
						$(this).parents(".boxthead").next(".boxbody").find(
								"tr:visible").find(
								"td:first input[type=checkbox]").prop(
								"checked", false);
					}
				});
	</script>
</body>
</html>